package com.situ.mall.order.config;

import com.situ.mall.base.util.C;
import com.situ.mall.base.util.URLUtil;
import com.situ.mall.order.interceptor.LoginInterceptor;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * ClassName: OrderWebMvcConfig
 * Package: com.situ.mall.order.config
 * Description:
 *
 * @Author Darling_达
 * @Create 2023-03-20 14:24
 * @Version 1.0
 */

@Configuration
public class OrderWebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(@NotNull InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/cart/**");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(C.UPLOAD_PATH_PREFIX + "**")
                .addResourceLocations(C.FILE + C.AVATAR_PATH)
                .addResourceLocations(C.FILE + C.PRODUCT_PATH)
                .addResourceLocations(C.FILE + C.BANNER_PATH);
    }


}
